music_flac.c
changeset 473 60b7e1c4f6b2
parent 470 5cebd6c5be2d
child 487 485a29de2b2d
equal deleted inserted replaced
472:463ba3222193 473:60b7e1c4f6b2
    97 									FLAC__uint64 absolute_byte_offset,
    97 									FLAC__uint64 absolute_byte_offset,
    98 									void *client_data)
    98 									void *client_data)
    99 {
    99 {
   100 	FLAC_music *data = (FLAC_music*)client_data;
   100 	FLAC_music *data = (FLAC_music*)client_data;
   101 
   101 
   102 	if (SDL_RWseek (data->rwops, absolute_byte_offset, SEEK_SET) < 0) {
   102 	if (SDL_RWseek (data->rwops, absolute_byte_offset, RW_SEEK_SET) < 0) {
   103 		return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
   103 		return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
   104 	}
   104 	}
   105 	else {
   105 	else {
   106 		return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
   106 		return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
   107 	}
   107 	}
   131 									void *client_data)
   131 									void *client_data)
   132 {
   132 {
   133 	FLAC_music *data = (FLAC_music*)client_data;
   133 	FLAC_music *data = (FLAC_music*)client_data;
   134 
   134 
   135 	int pos = SDL_RWtell (data->rwops);
   135 	int pos = SDL_RWtell (data->rwops);
   136 	int length = SDL_RWseek (data->rwops, 0, SEEK_END);
   136 	int length = SDL_RWseek (data->rwops, 0, RW_SEEK_END);
   137 
   137 
   138 	if (SDL_RWseek (data->rwops, pos, SEEK_SET) != pos || length < 0) {
   138 	if (SDL_RWseek (data->rwops, pos, RW_SEEK_SET) != pos || length < 0) {
   139 		/* there was an error attempting to return the stream to the original
   139 		/* there was an error attempting to return the stream to the original
   140 		 * position, or the length was invalid. */
   140 		 * position, or the length was invalid. */
   141 		return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
   141 		return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
   142 	}
   142 	}
   143 	else {
   143 	else {
   151 								void *client_data )
   151 								void *client_data )
   152 {
   152 {
   153 	FLAC_music *data = (FLAC_music*)client_data;
   153 	FLAC_music *data = (FLAC_music*)client_data;
   154 
   154 
   155 	int pos = SDL_RWtell (data->rwops);
   155 	int pos = SDL_RWtell (data->rwops);
   156 	int end = SDL_RWseek (data->rwops, 0, SEEK_END);
   156 	int end = SDL_RWseek (data->rwops, 0, RW_SEEK_END);
   157 
   157 
   158 	// was the original position equal to the end (a.k.a. the seek didn't move)?
   158 	// was the original position equal to the end (a.k.a. the seek didn't move)?
   159 	if (pos == end) {
   159 	if (pos == end) {
   160 		// must be EOF
   160 		// must be EOF
   161 		return true;
   161 		return true;
   162 	}
   162 	}
   163 	else {
   163 	else {
   164 		// not EOF, return to the original position
   164 		// not EOF, return to the original position
   165 		SDL_RWseek (data->rwops, pos, SEEK_SET);
   165 		SDL_RWseek (data->rwops, pos, RW_SEEK_SET);
   166 
   166 
   167 		return false;
   167 		return false;
   168 	}
   168 	}
   169 }
   169 }
   170 
   170