bool
GMPAudioDecoderParent::RecvDecoded(const GMPAudioDecodedSampleData& aDecoded)
{
  if (!mCallback) {
    return false;
  }

  mCallback->Decoded(aDecoded.mData(),
                     aDecoded.mTimeStamp(),
                     aDecoded.mChannelCount(),
                     aDecoded.mSamplesPerSecond());

  return true;
}
void
GMPAudioDecoderChild::Decoded(GMPAudioSamples* aDecodedSamples)
{
  MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());

  if (!aDecodedSamples) {
    MOZ_CRASH("Not given decoded audio samples!");
  }

  GMPAudioDecodedSampleData samples;
  samples.mData().AppendElements((int16_t*)aDecodedSamples->Buffer(),
                                 aDecodedSamples->Size() / sizeof(int16_t));
  samples.mTimeStamp() = aDecodedSamples->TimeStamp();
  samples.mChannelCount() = aDecodedSamples->Channels();
  samples.mSamplesPerSecond() = aDecodedSamples->Rate();

  Unused << SendDecoded(samples);

  aDecodedSamples->Destroy();
}