| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "platform/audio/AudioFileReader.h" | 29 #include "platform/audio/AudioFileReader.h" |
| 30 | 30 |
| 31 #include "platform/audio/AudioBus.h" | 31 #include "platform/audio/AudioBus.h" |
| 32 #include "public/platform/Platform.h" | 32 #include "public/platform/Platform.h" |
| 33 #include "public/platform/WebAudioBus.h" | 33 #include "public/platform/WebAudioBus.h" |
| 34 | 34 |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 PassRefPtr<AudioBus> decodeAudioFileData(const char* data, size_t size, double s
ampleRate) | 37 PassRefPtr<AudioBus> decodeAudioFileData(const char* data, size_t size, double s
ampleRate) |
| 38 { | 38 { |
| 39 WebKit::WebAudioBus webAudioBus; | 39 blink::WebAudioBus webAudioBus; |
| 40 if (WebKit::Platform::current()->loadAudioResource(&webAudioBus, data, size,
sampleRate)) | 40 if (blink::Platform::current()->loadAudioResource(&webAudioBus, data, size,
sampleRate)) |
| 41 return webAudioBus.release(); | 41 return webAudioBus.release(); |
| 42 return 0; | 42 return 0; |
| 43 } | 43 } |
| 44 | 44 |
| 45 PassRefPtr<AudioBus> AudioBus::loadPlatformResource(const char* name, float samp
leRate) | 45 PassRefPtr<AudioBus> AudioBus::loadPlatformResource(const char* name, float samp
leRate) |
| 46 { | 46 { |
| 47 const WebKit::WebData& resource = WebKit::Platform::current()->loadResource(
name); | 47 const blink::WebData& resource = blink::Platform::current()->loadResource(na
me); |
| 48 if (resource.isEmpty()) | 48 if (resource.isEmpty()) |
| 49 return 0; | 49 return 0; |
| 50 | 50 |
| 51 // FIXME: the sampleRate parameter is ignored. It should be removed from the
API. | 51 // FIXME: the sampleRate parameter is ignored. It should be removed from the
API. |
| 52 RefPtr<AudioBus> audioBus = decodeAudioFileData(resource.data(), resource.si
ze(), sampleRate); | 52 RefPtr<AudioBus> audioBus = decodeAudioFileData(resource.data(), resource.si
ze(), sampleRate); |
| 53 | 53 |
| 54 if (!audioBus.get()) | 54 if (!audioBus.get()) |
| 55 return 0; | 55 return 0; |
| 56 | 56 |
| 57 // If the bus is already at the requested sample-rate then return as is. | 57 // If the bus is already at the requested sample-rate then return as is. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 // If the bus needs no conversion then return as is. | 71 // If the bus needs no conversion then return as is. |
| 72 if ((!mixToMono || audioBus->numberOfChannels() == 1) && audioBus->sampleRat
e() == sampleRate) | 72 if ((!mixToMono || audioBus->numberOfChannels() == 1) && audioBus->sampleRat
e() == sampleRate) |
| 73 return audioBus; | 73 return audioBus; |
| 74 | 74 |
| 75 return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, sam
pleRate); | 75 return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, sam
pleRate); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace WebCore | 78 } // namespace WebCore |
| 79 | 79 |
| 80 #endif // ENABLE(WEB_AUDIO) | 80 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |